package com.sanrenzu.everybodytv.ui.recommend_live;

import android.os.Handler;

import com.sanrenzu.everybodytv.bean.sms.live.ZhiBoBean;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by asus on 2016/9/7.
 */
public class VdeoViewPresenter implements VideoViewContract.Presenter  {

    private VideoViewContract.View view;
    private VideoViewContract.Model model;
    private Handler handler = new Handler();
    private ZhiBoBean body;

    public VdeoViewPresenter(VideoViewContract.View view){
        this.view = view;
        this.model = new VideoViewModel();
    }

    @Override
    public void getVideoViewBean(String id) {
        model.getVideoView(id, new Callback<ZhiBoBean>() {
            @Override
            public void onResponse(Call<ZhiBoBean> call, Response<ZhiBoBean> response) {
                body = response.body();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getVideoViewSuccess(body);
                    }
                });
            }

            @Override
            public void onFailure(Call<ZhiBoBean> call, Throwable t) {
                view.getVideoViewFail("网络连接失败");
                t.printStackTrace();
            }
        });
    }
}
